package com.tcs.check;

import java.lang.reflect.Field;

/**
 * 验证
 * @author wangbo
 * @param <P>
 */
public class CheckParams<P> implements ICheckParams<P> {

	@Override
	public boolean check(P p) throws NullPointerException, IllegalArgumentException, IllegalAccessException {
		Class<? extends Object> clazz = p.getClass();
		Field [] fieldArray = clazz.getDeclaredFields();
		for (Field field : fieldArray) {
			field.setAccessible(true);
			Object obj = field.get(p);
			if (null == obj) {
				throw new NullPointerException(field.getName() + "不可为空!");
			}
		}
		return true;
	}
}